<?php
use app\common\services\UrlServices;

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=750">
    <title>九洲口令，红包百应</title>
    <script type="text/javascript" src="<?=UrlServices::buildWWWUrl('/hongbao/js/vie.js')?>"></script>
    <link rel="stylesheet" href="<?=UrlServices::buildWWWUrl('/hongbao/css/common.css')?>">
    <link rel="stylesheet" href="<?=UrlServices::buildWWWUrl('/hongbao/css/myprize.css')?>">
</head>
<body>
<div class="container">
    <h3><?php if(empty($info['store'])):?><?=$info['prize_name']?><?php else:?><?=$info['store'][0]['store_name']?><?php endif;?></h3>
    <?php if(!empty($info['store'])):?>
        <p class="time">使用有效期：<?=date('Y.m.d',$info['store'][0]['ks_time'])?> 至 <?=date('Y.m.d',$info['store'][0]['js_time'])?></p>
        <div class="rule">
            <p>使用规则</p>
            <?=$info['store'][0]['huodong_content']?>
        </div>
    <?php else:?>
        <p class="time">领取时间：2018.03.08 至 2018.04.01</p>
    <?php endif;?>
    <p class="prompt">请工作人员输入兑奖码</p>
    <input type="text" placeholder="输入兑奖码..." id="check_code">
    <div class="sure"></div>
    <input type="hidden" id="prize_id" value="<?=$info['id']?>">
</div>
<script src="<?=UrlServices::buildWWWUrl('/hongbao/js/jquery.min.js')?>"></script>
<script>
    $(document).ready(function(){
        $('.sure').click(function(){
           var code = $('#check_code').val();
           if(code.length<1){
               alert('请填写兑换码');
               return false;
           };
            $.ajax({
                url:'/weixin/activity/cash',
                type:"POST",
                dataType:'json',
                data:{
                    code:code,
                    id:$('#prize_id').val(),
                },
                success:function(res){
                    if(res.code == 200){
                        alert(res.msg);
                        window.location.href = '/weixin/activity/prize-list?is_code=1';
                    }
                }
            });
        });
    });

</script>
</body>
</html>
